package com.bibrApp.difu.actvity.order_message_mvp;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;

import com.bibrApp.difu.R;
import com.bibrApp.difu.base.BaseActivity;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class OrderMessageActivity extends BaseActivity<OrderMessagePresenter> implements IOrderMessageView {


    @BindView(R.id.recycler_view)
    RecyclerView recyclerView;


    private OrderMessageAdapter adapter;
    int pageNum = 1;

    @Override
    protected void initPresenter() {
        presenter = new OrderMessagePresenter(this, this);
        presenter.init();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_order_message;
    }

    @Override
    public void error(String msg) {

    }

    @Override
    public void success(String msg) {

    }

    @Override
    public void onDataResult(List<OrderMessageBean> datas) {
        if (pageNum == 1 && (datas == null || datas.size() == 0) && adapter.getEmptyViewCount() == 0) {
            adapter.setEmptyView(View.inflate(this, R.layout.empty_order, null));
        } else {
            adapter.setNewData(datas);
        }

    }

    @Override
    public void initView() {

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new OrderMessageAdapter();
        recyclerView.setAdapter(adapter);

        presenter.getDatas(pageNum);
    }

    @OnClick(R.id.bt_back)
    public void backClick() {
        finish();
    }
}
